﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Iterator_Pattern
{
    class DiscJockey
    {
        public SongIterator iter70sSongs;
        public SongIterator iter80sSongs;
        public SongIterator iter90sSongs;

        public DiscJockey(SongIterator songs70s, SongIterator songs80s, SongIterator songs90s)
        {
            this.iter70sSongs = songs70s;
            this.iter80sSongs = songs80s;
            this.iter90sSongs = songs90s;
        }

        public void showTheSongs()
        {
            IEnumerator songs70s = iter70sSongs.createIterator();
            IEnumerator songs80s = iter80sSongs.createIterator();
            IEnumerator songs90s = iter90sSongs.createIterator();

            Console.WriteLine("Songs of the 70s");
            printTheSongs(songs70s);

            Console.WriteLine("\nSongs of the 80s");
            printTheSongs(songs80s);

            Console.WriteLine("\nSongs of the 90s");
            printTheSongs(songs90s);
        }

        public void printTheSongs(IEnumerator iterator)
        {
            while (iterator.MoveNext())
            {
                SongInfo songInfo = (SongInfo)iterator.Current;
                Console.WriteLine("Title: " + songInfo.songName + ", Band: " + songInfo.bandName + ", Year released: " + songInfo.yearReleased);
            }
        }
    }
}
